package main.java.person.fjsp.algorithm.ts.entity;



import java.util.*;

/**
 * 析取图
 * @author xcy
 */
public class DisjunctiveGraph {
    /**
     * 析取弧的节点列表
     */
    private List<DisjunctiveGraphNode> nodes;
    /**
     * 析取图中的节点按照其所属机器号分组
     */
    private Map<Integer,List<Integer>> machineAndNodeListMap;
    /**
     * 析取图中的节点按照其作业号分组
     */
    private Map<Integer,List<Integer>> jobAndNodeListMap;
    /**
     * 关键路径（节点的序号）
     */
    private List<Integer> criticalPath;
    /**
     * 完工时间
     */
    private int makespan;
    /**
     * 该析取图是通过何种k-insertion得到的
     */
    private int[] insertInfo;

    public DisjunctiveGraph(List<DisjunctiveGraphNode> nodes, Map<Integer, List<Integer>> machineAndNodeListMap, Map<Integer, List<Integer>> jobAndNodeListMap, List<Integer> criticalPath, int makespan, int[] insertInfo) {
        this.nodes = nodes;
        this.machineAndNodeListMap = machineAndNodeListMap;
        this.jobAndNodeListMap = jobAndNodeListMap;
        this.criticalPath = criticalPath;
        this.makespan = makespan;
        this.insertInfo = insertInfo;
    }

    public List<DisjunctiveGraphNode> getNodes() {
        return nodes;
    }

    public void setNodes(List<DisjunctiveGraphNode> nodes) {
        this.nodes = nodes;
    }

    public Map<Integer, List<Integer>> getMachineAndNodeListMap() {
        return machineAndNodeListMap;
    }

    public void setMachineAndNodeListMap(Map<Integer, List<Integer>> machineAndNodeListMap) {
        this.machineAndNodeListMap = machineAndNodeListMap;
    }

    public List<Integer> getCriticalPath() {
        return criticalPath;
    }

    public void setCriticalPath(List<Integer> criticalPath) {
        this.criticalPath = criticalPath;
    }

    public int getMakespan() {
        return makespan;
    }

    public void setMakespan(int makespan) {
        this.makespan = makespan;
    }

    public Map<Integer, List<Integer>> getJobAndNodeListMap() {
        return jobAndNodeListMap;
    }

    public void setJobAndNodeListMap(Map<Integer, List<Integer>> jobAndNodeListMap) {
        this.jobAndNodeListMap = jobAndNodeListMap;
    }

    public int[] getInsertInfo() {
        return insertInfo;
    }

    public void setInsertInfo(int[] insertInfo) {
        this.insertInfo = insertInfo;
    }

    public DisjunctiveGraph clone(){
        List<DisjunctiveGraphNode> cloneNodes=new ArrayList<>(this.nodes.size());
        for (DisjunctiveGraphNode node : this.nodes) {
            cloneNodes.add(node.clone());
        }

        Map<Integer,List<Integer>> cloneMachineMap=new HashMap<>(this.machineAndNodeListMap.size());
        for (Map.Entry<Integer, List<Integer>> integerListEntry : this.machineAndNodeListMap.entrySet()) {
            cloneMachineMap.put(integerListEntry.getKey(),new ArrayList<>(integerListEntry.getValue()));
        }
        Map<Integer,List<Integer>> cloneJobMap=new HashMap<>(this.jobAndNodeListMap.size());
        for (Map.Entry<Integer, List<Integer>> integerListEntry : this.jobAndNodeListMap.entrySet()) {
            cloneJobMap.put(integerListEntry.getKey(),new ArrayList<>(integerListEntry.getValue()));
        }
        return new DisjunctiveGraph(cloneNodes,cloneMachineMap,cloneJobMap,new ArrayList<>(this.criticalPath),this.makespan, insertInfo);

    }
}
